package com.ceres.device.web.dao;

import com.ceres.device.pojo.CustomerDevice;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.repository.query.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface CustomerDeviceMapper extends Mapper<CustomerDevice>{

    /**
     * 用户自己的设备分类查询  mbgmjf
     * @param deviceType
     * @return
     */
    @Select("select * from t_customer_device where type=#{deviceType}")
    List<CustomerDevice> findByDeviceType(@Param("deviceType")String deviceType);

    /**
     * 根据id删除该设备
     * @param id
     */
    @Delete("delete from t_customer_device WHERE id = #{id}")
    void deleteById(Integer id);

    //查询设备安装状态字段
    @Select("select install from t_customer_device where id=#{id}")
    String findByInstall(Integer id);

    /**
     * 修改设备基本信息
     * @param customerDevice
     * @return
     */
    @Update("update t_customer_device set name=#{name},type=#{type},brand=#{brand},model=#{model},install=#{install},remarks=#{remarks} where id = #{id}")
    Integer updateById(CustomerDevice customerDevice);

}
